//
//  XGTextField.m
//  BSBuDeJie
//
//  Created by monkey on 2018/12/14.
//  Copyright © 2018 itcast. All rights reserved.
//

#import "XGTextField.h"

@implementation XGTextField

#pragma mark - 构造方法

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
    }
    
    return self;
}

- (void)setUpUI
{
    self.tintColor = [UIColor whiteColor];
    self.textColor = [UIColor whiteColor];
    [self addTarget:self action:@selector(textBeginEdit) forControlEvents:UIControlEventEditingDidBegin];
    [self addTarget:self action:@selector(textEditEnd) forControlEvents:UIControlEventEditingDidEnd];
}

#pragma mark - 事件监听

- (void)textBeginEdit
{
    [self setPlaceHolderColor:[UIColor whiteColor]];
}

- (void)textEditEnd
{
    [self setPlaceHolderColor:[UIColor darkGrayColor]];
}

- (void)setPlaceHolderColor:(UIColor *)placeHolderColor
{
    UILabel *placeholderLabel = [self valueForKey:@"placeholderLabel"];
    placeholderLabel.textColor = placeHolderColor;
}

@end
